package org.ctstudio.oa.duty.web;

import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Map;

import org.ctstudio.common.utils.LocalDateEditor;
import org.ctstudio.common.utils.LocalTimeEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.ModelAttribute;

public class AbstractApplyController extends AbstractController {
  @ModelAttribute("applyStatus")
  public Map<Long, String> getApplyStatus() {
    return getSettings("apply.status");
  }

  @ModelAttribute("approveStatus")
  public Map<Long, String> getApproveStatus() {
    return getSettings("approve.status");
  }

  @InitBinder
  public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(LocalDate.class, new LocalDateEditor());
    binder.registerCustomEditor(LocalTime.class, new LocalTimeEditor());
  }
}
